package cn.xinfei.xdecision.model;

import cn.xinfei.xdecision.common.model.enginex.model.RuleHitModel;
import cn.xinfei.xdecision.common.model.enginex.model.RuleSetDecisionResultData;
import cn.xinfei.xdecision.constant.EngineResultEnum;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import cn.xinfei.xdecision.common.utils.util.JsonUtil;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DecisionApiResponse {

    private String sign; // 签名
    private String bizEnc; // biz_data加密方式（0不加密，1加密）

    private String requestId;
    private String decisionId;
    private String engineCode;
    private String versionNo;
    private String code;
    private String state;
    private String result;
    private String msg;
    private long respond;
    private Map<String, Object> in;
    private Map<String, Object> out;
    private List<RuleHitModel> hitResultList;
    private List<RuleSetDecisionResultData> branchRejectInfo;


    public void setEngineResult(EngineResultEnum engineResultEnum) {
        this.state = engineResultEnum.getState();
        this.code = engineResultEnum.getCode();
        this.msg = engineResultEnum.getMsg();
        this.result = engineResultEnum.getResult();
    }


    @Override
    public String toString() {
        return JsonUtil.toJson(this);
    }
}
